package com.cesgroup.zw.spring.boot.library.echarts.lineAndBar.complex;

import com.cesgroup.zw.spring.boot.echarts.build.EChartsOption;
import com.cesgroup.zw.spring.boot.echarts.component.*;
import com.cesgroup.zw.spring.boot.echarts.component.axis.XAxis;
import com.cesgroup.zw.spring.boot.echarts.component.axis.YAxis;
import com.cesgroup.zw.spring.boot.echarts.enums.AxisPointerType;
import com.cesgroup.zw.spring.boot.echarts.enums.AxisType;
import com.cesgroup.zw.spring.boot.echarts.enums.Position;
import com.cesgroup.zw.spring.boot.echarts.enums.Trigger;
import com.cesgroup.zw.spring.boot.echarts.model.axis.*;
import com.cesgroup.zw.spring.boot.echarts.model.axis.AxisPointer;
import com.cesgroup.zw.spring.boot.echarts.model.style.AreaStyle;
import com.cesgroup.zw.spring.boot.echarts.model.style.LabelStyle;
import com.cesgroup.zw.spring.boot.echarts.model.style.LineStyle;
import com.cesgroup.zw.spring.boot.echarts.model.style.RichTextStyle;

import java.util.List;

/**
 * <p>复杂折线和柱状图</p>
 * @author ytj
 * @date 2019/7/4 13:07
 */
@SuppressWarnings("serial")
public class ComplexLineAndBarOption extends EChartsOption{
    public ComplexLineAndBarOption(ComplexLineAndBarParam param){
        this.setTitle(new Title(){{
            this.setText(param.getTitle());
            this.setTextStyle(new RichTextStyle(){{
                this.setColor("#fff");
                this.setFontSize(20);
            }});
            this.setTop("3%");
            this.setLeft("10%");
        }});
        this.setBackgroundColor("#0f375f");
        this.setGrid(new Grid(){{
            this.setTop("25%");
            this.setBottom("10%");
        }});
        this.setTooltip(new Tooltip(){{
            this.setTrigger(Trigger.axis);
            this.setAxisPointer(new AxisPointer(){{
                this.setType(AxisPointerType.shadow);
                this.setLabel(new LabelStyle(){{
                    this.setShow(true);
                }});
            }});
        }});
        this.setLegend(new Legend(){{
            this.setTop("15%");
            this.setTextStyle(new RichTextStyle(){{
                this.setColor("#ffffff");
            }});
        }});
        this.setXAxis(new XAxis(){{
            this.setData((List<Object>)param.getDataset().get("productor"));
            this.setAxisLine(new AxisLine(){{
                this.setShow(true);
            }});
            this.setAxisTick(new AxisTick(){{
                this.setShow(true);
            }});
            this.setAxisLabel(new AxisLabel(){{
                this.setShow(true);
            }});
            this.setAxisLine(new AxisLine(){{
                this.setLineStyle(new LineStyle(){{
                    this.setColor("#01FCE3");
                }});
            }});
        }});
        this.setYAxis(new YAxis[]{
                new YAxis(){{
                    this.setType(AxisType.value);
                    this.setName(param.getLeft());
                    this.setNameTextStyle(new TextStyle(){{
                        this.setColor("#ebf8ac");
                    }});
                    this.setSplitLine(new SplitLine(){{
                        this.setShow(false);
                    }});
                    this.setAxisTick(new AxisTick(){{
                        this.setShow(true);
                    }});
                    this.setAxisLine(new AxisLine(){{
                        this.setShow(true);
                    }});
                    this.setAxisLabel(new AxisLabel(){{
                        this.setShow(true);
                    }});
                    this.setAxisLine(new AxisLine(){{
                        this.setLineStyle(new LineStyle(){{
                            this.setColor("#FFFFFF");
                        }});
                    }});
                }},
                new YAxis(){{
                    this.setType(AxisType.value);
                    this.setGridIndex(0);
                    this.setMin(50);
                    this.setMax(100);
                    this.setSplitNumber(8);
                    this.setSplitLine(new SplitLine(){{
                        this.setShow(false);
                    }});
                    this.setAxisLine(new AxisLine(){{
                        this.setShow(false);
                    }});
                    this.setAxisTick(new AxisTick(){{
                        this.setShow(false);
                    }});
                    this.setAxisLabel(new AxisLabel(){{
                        this.setShow(false);
                    }});
                    this.setSplitArea(new SplitArea(){{
                        this.setShow(true);
                        this.setAreaStyle(new AreaStyle(){{
                            this.setColor(new String[]{"rgba(250,250,250,0.0)", "rgba(250,250,250,0.05)"});
                        }});
                    }});
                }}
        });
    }
}
